package com.tanhua.dubbo.job;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.Set;

@Component
@Slf4j
public class SoundRedisJob {

    @Autowired(required = false)
    private RedisTemplate<String, String> redisTemplate;

    @Scheduled(cron = "0 0 6 * * ?")
    public void deleteSoundRedis(){
        String prex = "tanhua_sound_*";
        Set<String> keySet = redisTemplate.keys(prex);
        if(!CollectionUtils.isEmpty(keySet)){
            redisTemplate.delete(keySet);
        }
    }
}
